﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Agents.Agent
{
    //on this page the agent enters his current location, this information is forwarded
    //to the algorithm for choosing his nexed client (based on his location and other kriterea)
    public partial class FindCustomer : System.Web.UI.Page
    {
        //for holding agent information and location
        string param, param2, city, street, number;
        protected void Page_Load(object sender, EventArgs e)
        {
            //retrieving agents information from previouse page.
            param = Request.QueryString["param"];
            param2 = Request.QueryString["param2"];

            //retrieving location information from textbox
            city = cityTxtbox.Text;
            street = streetTxtbox.Text;
            number = numberTxtbox.Text;
        }

        //function for redirecting the agent to his homepage.
        protected void backBtn_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Agent/AgentMenu.aspx");
        }

        //this function is activated when the ok button is pressed
        protected void okBtn_Click(object sender, EventArgs e)
        {
            //if there is an empty field- do nothing
            if (city == "" || street == "" || number == "") { }

            else
            {
                //creating the apropriate format of address for the algorithm.
                string address = city + "," + street + "," + number;
                //sending agent and location information to the algorithm page.
                Response.Redirect("~/Agent/QueryNoMap.aspx?address=" + address);
            }
        }
    }
}